﻿using Helper;
using HZY.Framework.DependencyInjection.Attributes;
using Microsoft.Extensions.DependencyInjection;
using Sunny.UI;

namespace Yale.SprayProcessSCADASystem
{
    public delegate void FrmStartLoadSchedule(int num);
    [ComponentAttribute(ServiceLifetime.Singleton)]
    public partial class FormStartLoad : UIForm, ISplashForm
    {
        public FormStartLoad()
        {
            InitializeComponent();

            //this.ClientSize = new System.Drawing.Size(436, 312);
            //this.Name = "FromStartLoad";
            //this.ResumeLayout(false);
        }
        //用于处理数据的等待弹框
        public static UIWaitForm MsgTips = new UIWaitForm("系统加载中...");



        private void ThreadFunc()
        {
            if (MsgTips.IsDisposed)
            {
                MsgTips = new UIWaitForm("系统加载中...");
            }

            //Label lab = new Label();//在弹框中加入文字提示
            //PictureBox Pic = new PictureBox();//在弹框中加入图片


            //MsgTips.AutoScaleDimensions = new SizeF(8F, 15F);
            //MsgTips.AutoScaleMode = AutoScaleMode.Font;
            //MsgTips.ClientSize = new Size(377, 303);
            //MsgTips.Controls.Add(lab);
            //MsgTips.Controls.Add(Pic);

            //MsgTips.FormBorderStyle = FormBorderStyle.None;
            //MsgTips.Opacity = 1D;
            //MsgTips.StartPosition = FormStartPosition.CenterScreen;
            //MsgTips.BackColor = Color.Red;
            //MsgTips.TransparencyKey = Color.Red;




            Application.Run(MsgTips);





            //MsgTips.BackColor = Color.Red;
        }

        public void OpenFormThread()
        {
            //ThreadStart Thrad = new ThreadStart(ThreadFunc);//相当于指针函数，绑定了一个方法
            //Thread FormThread = new Thread(Thrad);
            //FormThread.IsBackground = true;
            //FormThread.SetApartmentState(ApartmentState.STA);
            //FormThread.Start();
            //this.Enabled = false;
            //this.Opacity = 0.95D;
        }


        public void CloseFormThread()
        {
            if (MsgTips.InvokeRequired)
            {
                MsgTips.Invoke(new Action(() =>
                {

                    MsgTips.Close();
                    MsgTips.Dispose();
                    this.Opacity = 1D;
                    this.Enabled = true;
                }));

            }
            else
            {
                MsgTips.Close();
                MsgTips.Dispose();
                this.Opacity = 1D;
                this.Enabled = true;
            }

        }

        public void SetStatusInfo(string NewStatusInfo)
        {
            uiLabel2.Text = NewStatusInfo;
        }
    }
}
